TEC Historic Arbitrage Depth Analysis

Using historic data to populate liquidity models and calculate arbitrage depth
from conding.pamm.abc import AugmentedBondingCurve
from conding.dune.tec import TECDashboard
import pandas as pd
tec = TECDashboard()

Current State of the ABC

supply = tec.market_information.supply(update_cache=False)
reserve_balance = tec.reserves.reserve_pool_value(update_cache=False)
common_pool = tec.reserves.common_pool_value(update_cache=False)

(supply, reserve_balance, common_pool)
(1750465.5804850913, 204683.0971086502, 394287.5652695778)
entry_tribute = 0.02
exit_tribute  = 0.12
price = 0.53

Initialize an ABC model for the current state of TEC ABC.

abc = AugmentedBondingCurve(
    price=price, 
    supply=supply, 
    reserve_balance=reserve_balance, 
    entry_tribute=entry_tribute, 
    exit_tribute=exit_tribute, 
    common_pool=common_pool
)
abc.view()

Loading Historical TEC ABC Mints and Burns

### Load ABC token sales data
abc_token_sales = tec.trades.abc_token_sales()


### Shift data such that purchase amount is aligned with initial state instead of final state
abc_token_sales[['paidAmount','amountBought','tribute', 'price_per_token']] = abc_token_sales[['paidAmount','amountBought','tribute', 'price_per_token']].shift(1)
abc_token_sales[['diff']] = abc_token_sales[['diff']].shift(2)


### Convert sells to negative buys
abc_token_sales.loc[abc_token_sales['action']=='Sell', ['paidAmount', 'amountBought']] = -abc_token_sales[abc_token_sales['action']=='Sell'][['paidAmount', 'amountBought']] 


### Rename the columns to match
abc_token_sales = abc_token_sales.rename({
    'cumulative_supply':'supply', 
    'price_per_token': 'execution_price', 
    'paidAmount': 'deposit', 
    'amountBought': 'mint_amount'
},axis=1)

abc_token_sales.head()
block_time tx_hash action reserve_balance supply deposit mint_amount tribute execution_price diff
0 2023-06-26T22:04:15Z <a href="https://blockscout.com/xdai/mainnet/t... Sell 204683.097109 1.750466e+06 NaN NaN NaN NaN None
1 2023-06-26T21:47:40Z <a href="https://blockscout.com/xdai/mainnet/t... Sell 204697.179384 1.750489e+06 -12.392402 -23.869 1.689873 0.589982 None
2 2023-06-26T20:19:40Z <a href="https://blockscout.com/xdai/mainnet/t... Sell 204702.182617 1.750498e+06 -4.402845 -8.480 0.600388 0.590004 -3.7380200181174674e-05
3 2023-06-26T16:33:00Z <a href="https://blockscout.com/xdai/mainnet/t... Sell 205179.513522 1.751306e+06 -420.051197 -808.267 57.279709 0.590561 -0.0009441995507981619
4 2023-06-26T15:32:50Z <a href="https://blockscout.com/xdai/mainnet/t... Sell 205238.631598 1.751406e+06 -52.023907 -100.000 7.094169 0.591181 -0.0010495683879868413
abc_token_sales.tail()
block_time tx_hash action reserve_balance supply deposit mint_amount tribute execution_price diff
2256 2022-01-25T09:22:35Z <a href="https://blockscout.com/xdai/mainnet/t... Buy 604458.124 2.169520e+06 142.00134 101.007155 40.05166 1.802377 9.93344313166947e-05
2257 2022-01-25T09:22:25Z <a href="https://blockscout.com/xdai/mainnet/t... Buy 603288.124 2.168687e+06 1170.00000 832.959191 330.00000 1.800809 0.0008703824349471555
2258 2022-01-25T09:22:25Z <a href="https://blockscout.com/xdai/mainnet/t... Buy 602059.624 2.167811e+06 1228.50000 876.002320 346.50000 1.797940 0.0024093177328280064
2259 2022-01-25T09:22:20Z <a href="https://blockscout.com/xdai/mainnet/t... Buy 602058.220 2.167810e+06 1.40400 1.001965 0.39600 1.796470 0.0008194194584005584
2260 2022-01-25T09:20:50Z <a href="https://blockscout.com/xdai/mainnet/t... Buy 602057.440 2.167810e+06 0.78000 0.556648 0.22000 1.796467 -0.000818635981467873
params = abc_token_sales.iloc[-1][['reserve_balance', 'supply', 'mint_amount', 'execution_price']].rename({'execution_price': 'price'}).to_dict()
params
{'reserve_balance': 602057.4400000001,
 'supply': 2167809.597439592,
 'mint_amount': 0.5566480773143038,
 'price': 1.7964671769365756}
abc = AugmentedBondingCurve(**params)
abc
AugmentedBondingCurve(common_pool=0, deposit=1.0000007023336366, entry_tribute=0.22, exit_tribute=0.02, m=4.036365233897545e-35, marketcap=3894398.787648318, mint=<function BondingCurve.<lambda>>, mint_amount=0.5566480773143038, mint_price=1.7964684386559011, mint_tribute=0.2820514801453846, n=5.468483783953102, name='AugmentedBondingCurve213265', new_price=1.7964696995229361, price=1.7964671769365756, reserve_balance=602057.4400000001, reserve_ratio=0.1545957342400366, supply=2167809.597439592, total_mint_deposit=1.2820521824790212, total_mint_price=2.3031646649434627)
# abc.param['mint_amount'].softbounds = (None,None)
abc.view()
import time

for m in abc_token_sales.iloc[::-1]['mint_amount'][:100]:
    abc.mint_amount = m
    print(m)
    abc._mint()
    time.sleep(0.1)
0.5566480773143038
1.0019650820226569
876.002319751027
832.9591914857209
101.00715501863084
5.547676859504
5.547619474949967
110.94034079646104
55.46156624867915
8131.741054767892
273.0596543892236
10462.795797870484
58.14294414162144
9589.525931735388
205.12271163993043
422.1633860624301
22.252272900065297
220.43271700833668
26.260043239337996
0.0525213575342681
943.4692982454072
3.669931548936833
1570.5531658264983
1463.9093708565815
1201.865272136768
208.04436163746345
124.71727904804423
472.9656605467586
78.43005559067952
2.5968287082472115
519.1172734894132
43.06452750039873
1.608368273195331
518.5780937292312
3.112957374276876
673.2588888784026
70.30170344081803
4.534898669033506
38.70272138857421
103.50708882955468
25.87370436123435
930.637271268966
103.30625543028152
5.164799603200605
2.2683645417885767
6.260678543983593
109.72478484648371
670.8630098126143
154.69756089644596
103.10736749078173
10.309666192804976
10.30947157923806
521.5737840113995
103.26830709775146
312.27724952055564
56.822686701769854
230.27951189241224
51.94333343012359
215.0874718244898
146.97467240916404
28.032883737417
25.694348045373783
410.9453880591241
312.1120169545381
21.273084678815536
2219.5933918085266
51.10737695371567
102.23160739473384
101.6704943907655
5.108571756499344
2268.0889762963197
100.21329249091804
3043.43861398355
303.41709131212934
32.95464857121173
505.2923367981235
252.4718405428499
50.48043725292471
254.35077789164376
25.73131240972813
504.29207140624567
181.43183900568732
1.5620694722064228
0.5038924304063093
498.6268796158749
531.9496872400268
50.29247709474156
24.64163352524051
221.2223143397101
108.06488649453286
75.38152480149843
25.12487749476326
207905.25541046244
174.9758270776424
85.65798943074329
32.54644367170936
3418.617039777708
239.9681459640134
3.8248045554768746
0.695416399136881